package com.hyt.it.ogt.kq.service.bm.service.impl;

import java.util.List;

import org.apache.commons.collections4.CollectionUtils;

import com.hyt.it.ogt.kq.service.bm.model.dto.ProjectStatusAttrDto;
import com.hyt.it.ogt.kq.service.bm.model.entity.Project;
import com.hyt.it.ogt.kq.service.bm.model.entity.ProjectSubject;

/**
 * service公用方法抽取
 * @author huangwu
 *
 */
public class BmBaseService {
    
    

	public static ProjectStatusAttrDto getSelectProjectStatusAttrDto(List<ProjectSubject> projectSubjects, Project project) {
		
		ProjectStatusAttrDto selectAllStudentStatusDto = new ProjectStatusAttrDto();
		
		String isAudit = "";
		String isPay = "";
		// 如果是需要审核
		if (project.getIsVerify().intValue() == 1) {
			isAudit = "1";
		}
		// 如果需要缴费
		if (project.getIsPay().intValue() == 1) {
			isPay = "1";
		}
		// 项目下的科目需不需要缴费
		int subispay = 0;
		// 这里主要处理的逻辑是项目需要缴费，但是科目不需要缴费
		if (CollectionUtils.isNotEmpty(projectSubjects)) {
			for (ProjectSubject projectSubject : projectSubjects) {
				subispay += projectSubject.getIsPay().intValue();
			}
		}
		if (subispay == 0) {
			isPay = null;
		}
		selectAllStudentStatusDto.setIsAudit(isAudit);
		selectAllStudentStatusDto.setIsPay(isPay);
		return selectAllStudentStatusDto;
	}
}
